package pen_exam.p_2024_04_07_smallredbook;

import java.util.Scanner;


//String 代表 i 和 i+1的关系
//每个数字范围在1 - m
//共n个数字问有多少种可能
//时间超限 1 <= n,m <=2000
public class Code03_count {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nm = sc.nextLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        String  s = sc.nextLine();// str = &lt;=&gt;
       s = s.replaceAll("&lt;","<").replaceAll("&gt;",">");
        char[] str = s.toCharArray();
        long res = dp(str,m);
        long[][] map = new long[n + 1][m + 1];
//       for(int i = 1;i <= m;i++){
//           res += process(str,1,i,m,map);
//       }
        System.out.println(res % 1000000007);
    }

    public static long dp(char[] str, int m) {
        int n = str.length;
        int[][] dp = new int[n + 2][m + 1];
        for (int i = 1; i <= m; i++) {
            dp[n + 1][i] = 1;
        }
        long res = 0;
        for (int index = n; index >= 1; index--) {
            for (int pre = 1; pre <= m; pre++) {
                char c = str[index - 1];
                if(c == '>'){
                    for(int i = 1;i < pre;i++){
                        dp[index][pre] += dp[index + 1][i] % 1000000007;
                    }
                }else if(c == '<'){
                    for(int i =  pre + 1;i <= m;i++){
                        dp[index][pre] += dp[index + 1][i]% 1000000007;
                    }
                }else{//=
                    dp[index][pre] += dp[index + 1][pre]% 1000000007;
                }
            }
        }
        for(int i = 1;i <= m;i++){
            res +=  dp[1][i]% 1000000007;
        }
        return res;
    }
    public static long process(char[] str,int index,int pre,int m,long[][] map){
        if(index == str.length + 1){
            map[index][pre] = 1;
            return 1;
        }
        if(map[index][pre] != 0){
            return map[index][pre];
        }
        int res = 0;
        char c = str[index - 1];
        if(c == '>'){
            for(int i = 1;i < pre;i++){
                res += process(str,index + 1,i,m,map);
            }
        }else if(c == '<'){
            for(int i =  pre + 1;i <= m;i++){
                res += process(str,index + 1,i,m,map);
            }
        }else{//=
            res += process(str,index + 1,pre,m,map);
        }
        map[index][pre] = res;
        return res;
    }
}
